package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

public class Bookcase {
    private static List<Book> bookcase = new ArrayList<Book>();

    public Bookcase() {
        bookcase.add(new Book("00001", "Crazy Java"));
        bookcase.add(new Book("00002", "Crazy Ruby"));
        bookcase.add(new Book("00003", "Crazy C++"));
    }

    public String returnBooks() {
        String summery = "";
        String separator = System.getProperty("line.separator");
        for (Book book : bookcase) {
            summery = summery + "BookId: " + book.getBookId() + "  BookName: " + book.getBookName() + separator;
        }
        return summery;
    }

    public String reserveBook(String bookId) {
        for (Book book : bookcase) {
            if (book.getBookId().equals(bookId)) {
                if (book.reserveBook()) {
                    return "Thank You! Enjoy the book.";
                }
                return "Sorry the book was reserved by other people.";
            }
        }
        return "Sorry we don't have that book yet.";
    }
}
